Skip to content

samples: a token template and a Python client that calls contracts with the declared types - #135

Merged
EnzinoBB merged 4 commits into
masterfrom
feat/sc-samples
Oct 30, 2026
Merged

EnzinoBB merged 4 commits into
masterfrom
feat/sc-samples

Conversation

@EnzinoBB

Copy link
Copy Markdown
Collaborator

Summary

  • samples/contracts/Token.java: a token template to start from, SmartContract v3 + ExtensionTokenStandard v1 (token standard 4, recognised by wallets and the token API). Compared with the templates around: every amount is checked (positive, no more decimals than the token has: no dust), balances and allowances are kept at the token's scale (5 and 5.000 are one value), approve() sets the allowance as ERC-20 does instead of adding to it, payable() sells tokens for CS at a price, owner-only freeze. The executor harness runs it on every executor (template_token), so the executor CI covers it.
  • samples/python/token_client.py: lists a contract's methods (SmartContractGet + ContractAllMethodsGet), reads a getter for free (TransactionFlow with forgetNewState) and signs and sends a call, converting every argument to the type the method declares (String, BigDecimal, int, long, boolean, double and wrappers, byte[]): the executor finds no method otherwise (api: refuse a contract call whose method the executor cannot find #132 refuses such calls before they are sent).
  • docs/tokens.md: a section on both.

Samples and CI only.

Test plan

  • Harness, release executor 1518 and the current executor: the template's scenario passes on both (deploy, standard 4, scale, refused decimals and negative amounts, ERC-20 approve, transferFrom, payable, freeze by the owner only, burn), 0 differing answers
  • Client on a private network: methods, get balanceOf, get getName, a signed call transfer <wallet> 1.5 (returned True, the balance read afterwards is 1.500), a wrong argument count reported with the method's signature

🤖 Generated with Claude Code

…th the declared types

samples/contracts/Token.java is a token to start from: SmartContract v3 and
ExtensionTokenStandard v1 (token standard 4). Every amount is checked (positive, at most the
token's decimals), balances and allowances are kept at the token's scale, approve() sets the
allowance as ERC-20 does instead of adding to it, payable() sells tokens for CS at a price.
The executor harness runs it on every executor (template_token).

samples/python/token_client.py lists a contract's methods (SmartContractGet, then
ContractAllMethodsGet), reads a getter through TransactionFlow with forgetNewState (free,
nothing sent) and signs and sends a call; each argument is converted to the type the method
declares (String, BigDecimal, int, long, boolean, double and wrappers, byte[]), which the
executor requires.
@EnzinoBB
EnzinoBB merged commit cfab208 into master Oct 30, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant